/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aso.upna.playlist;

import java.io.Serializable;
import java.util.Vector;

/**
 *
 * @author triki
 */
public class GenericList implements Serializable {

    private Vector priv_list;

    public GenericList()
    {
        priv_list = new Vector();
    }

    public GenericList(Vector v)
    {
        priv_list = (Vector) v.clone();
    }

    public int getCountElements()
    {
        return priv_list.size();
    }

    public void addElement(Object cancion)
    {
        priv_list.add(cancion);
    }

    public void addElements(Vector v)
    {
        int i = 0;

        for(i=0;i<v.size();i++)
        {
            priv_list.add(v.elementAt(i));
        }
    }

    public Object getElementAt(int pos)
    {
        return priv_list.elementAt(pos);
    }

    public void remove(Object obj)
    {
        priv_list.remove(obj);
    }
    
    public void removeAll()
    {
        priv_list.removeAllElements();
    }

    public GenericIterator getIterator()
    {
        return new GenericIterator(priv_list);
    }

    public static GenericList mergeLists(GenericList l1,GenericList l2)
    {
        GenericIterator it;
        GenericList list;
        list = new GenericList();

        it = l1.getIterator();

        while(it.hasNext())
        {
            list.addElement(it.current());
            it.next();
        }
        it = l2.getIterator();
        
        while(it.hasNext())
        {
            list.addElement(it.current());
            it.next();
        }

        return list;
    }
}
